#include "watch.h"
#include "ui_watch.h"
#include <QChart>
#include <QCandlestickSeries>
#include <QtCharts/QCandlestickSeries>
#include <QHBoxLayout>
#include <QVBoxLayout>

Watch::Watch(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Watch)
{
    ui->setupUi(this);
    // 创建K线图控件
    klineWidget = new KLineWidget;
    //setCentralWidget(klineWidget);

    /*#ifdef TOOLBAR  */     // 创建工具栏
    QToolBar *toolBar = new QToolBar("主工具栏");


    // K线数量控制
    toolBar->addWidget(new QLabel("KLine num:"));
    QSpinBox *countSpin = new QSpinBox;
    countSpin->setRange(10, 500);
    countSpin->setValue(100);
    countSpin->setFixedWidth(80);
    connect(countSpin, QOverload<int>::of(&QSpinBox::valueChanged),
            klineWidget, &KLineWidget::setVisibleCount);
    connect(klineWidget, &KLineWidget::visibleCountChanged,
            countSpin, &QSpinBox::setValue);


    toolBar->addWidget(countSpin);

    // 技术指标选择
    toolBar->addSeparator();
    toolBar->addWidget(new QLabel("Tech Symbol:"));

    QComboBox *indicatorCombo = new QComboBox;
    indicatorCombo->addItem("all", 0);
    indicatorCombo->addItem("kline", 1);
    indicatorCombo->addItem("means", 2);
    indicatorCombo->addItem("manage", 3);
    indicatorCombo->setFixedWidth(120);
    connect(indicatorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
            this, &Watch::setIndicatorMode);
    toolBar->addWidget(indicatorCombo);

    // 操作提示
    toolBar->addSeparator();
    //#endif
    // 设置窗口属性
    //setWindowTitle("Qt K线图绘制系统");

    QVBoxLayout*lay=new QVBoxLayout(this);
    lay->setSpacing(0);
    lay->setMargin(0);
    lay->addWidget(toolBar);
    lay->addWidget(klineWidget);
    this->setLayout(lay);




}

Watch::~Watch()
{
    delete ui;
}
